package com.nantian.nfcm.bms.loan.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.nantian.nfcm.bms.loan.entity.MsgInfo;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MsgInfoDao extends JpaRepository<MsgInfo, Long>, JpaSpecificationExecutor<MsgInfo> {
    List<MsgInfo> findByUserName(String userName);

    List<MsgInfo> findByLoanId(String loanId);

    @Query("select max(id) from MsgInfo mi where mi.userName=?1 group by mi.loanId")
    List<Long> findIdByUserName(String userName);

    @Query("from MsgInfo mi where mi.id in (?1) order by mi.id asc ")
    List<MsgInfo> findByIds(List<Long> ids);
}
